package com.karaku.karaku_collector.util;

import android.content.Context;
import android.util.DisplayMetrics;
import android.view.WindowManager;

import com.karaku.karaku_collector.App;
import com.karaku.karaku_collector.util.Size;

/**
 * Created by guoping on 2017/11/7.
 */

public class UIUtil {
    public static int dp2px(float dp) {
        final float scale = App.getInstance().getResources().getDisplayMetrics().density;
        return (int) (dp * scale + 0.5f);
    }

    public static Size getScreenSize() {
        WindowManager manager = (WindowManager) App.getInstance().getSystemService(Context.WINDOW_SERVICE);
        DisplayMetrics outMetrics = new DisplayMetrics();
        manager.getDefaultDisplay().getMetrics(outMetrics);
        return new Size(outMetrics.widthPixels, outMetrics.heightPixels);
    }
}
